import Vue from 'vue'
import VueRouter from 'vue-router'
import Register from "@/views/login/Register";
import Login from "@/views/login/Login";
import Test from "@/components/test/Test";
import HcLayout from "@/layout/HcLayout";
import Overview from "@/pages/Overview";


import Eos from "@/components/xc/Eos";
import Statistics from "@/pages/statistics/OverallCurrentPerformanceStatistics";
import HistoryStatistics from "@/pages/statistics/OverallHistoryPerformanceStatistics";
import EthStatistics from "@/components/statistics/EthStatistics";
import EthClientStatistics from "@/components/statistics/EthClientStatistics";
import OPTStatistics from "@/components/statistics/OPTStatistics";
import GmetroStatistics from "@/components/statistics/GmetroStatistics";

//网元相关属性
//拓扑
import MeList from "@/components/topology/MeList";

//网元
import NECenter from "@/components/NECenter";
import MeParams from "@/components/topology/MeParams";
import NetworkElement from "@/components/dispose/me/NetworkElement";
//单板
import Eq from "@/components/dispose/eq/Eq";
import EqList from "@/components/dispose/me/EqList";
//端口
import Ptp from "@/components/dispose/ptp/Ptp";
import BatchConfigPtp from "@/components/dispose/eq/BatchConfigPtp";
//CTP
import CTP from "@/components/dispose/ctp/Ctp";
import CtpGeneral from "@/components/dispose/ctp/CtpGeneral";
//光模块
import OptModule from "@/components/dispose/opt/OptModule";
//性能查询设置
import CurrentPerformances from "@/components/performance/CurrentPerformances";
import HistoryPerformances from "@/components/performance/HistoryPerformances";
//告警相关
import CurrentAlarms from "@/components/alarms/CurrentAlarms";
import HistoricalAlarms from "@/components/alarms/HistoricalAlarms";
import AlarmsMaskState from "@/components/alarms/AlarmsMaskState";
//保护组
import PGParams from "@/components/dispose/pg/PGParams";
import PGList from "@/components/dispose/pg/PGList";
import LAG from "@/components/dispose/lag/LAG";
//远程配置
import UploadFtpFile from "@/components/system/rms/UploadFtpFile";
import DownloadFtpFile from "@/components/system/rms/DownloadFtpFile";
//交叉连接
import XcConnections from "@/components/xc/XcConnections";
import XcPac from "@/components/xc/XcPac";
import PtpList from "@/components/dispose/ptp/PtpList";
//性能
import Tcas from "@/components/performance/Tcas";
import MECurrentPerformanceStatistics from "@/pages/statistics/MECurrentPerformanceStatistics";
import MEHistoryPerformanceStatistics from "@/pages/statistics/MEHistoryPerformanceStatistics";
//测试
import THome from "@/components/test/Home";
import LCt from "@/components/test/LCt";
import tagsView from "@/components/test/tagsView";
import Test2 from "@/components/test/Test2";

Vue.use(VueRouter)
//获取原型对象的方法
const originalPush = VueRouter.prototype.push
//修改 原型对象中的push方法
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const routes = [
    {
        path: '/',
        component: HcLayout,
        redirect: "/oos",
    },
    {
        path: '/overview',
        name: 'Overview',
        component: Overview
    },
    {
        path: '/oos',
        name: 'HcLayout',
        component: HcLayout,
        children: [
            {
                path: 'only/test',
                component: LCt,
            },
            {
                path: 'test1',
                component: tagsView,
                children: [
                    {
                        path: 'me',
                        component: NetworkElement
                    },
                    {
                        path: 'eq',
                        component: Eq
                    },
                ]
            },
            {
                path: 'test2',
                name: 'Test2',
                component: Test2,
                children: [
                    {
                        path: 'me',
                        component: NetworkElement
                    },
                    {
                        path: 'eq',
                        component: Eq
                    },
                ]

            },
            {
                path: 'test/home',
                name: 'THome',
                component: THome
            },
            {
                path: 'ne_center/me',
                name: 'NetworkElement',
                component: NetworkElement
            },
            {
                name: 'EQ',
                path: 'ne_center/eq',
                component: Eq,
            },
            {
                path: 'ne_center/me/xcs',
                component: XcConnections,
            },
            {
                path: 'ne_center/xcs/config',
                component: XcPac
            },
            {
                path: 'ne_center/eqs/ptps',
                name: 'BatchConfigPtp',
                component: BatchConfigPtp,
            },
            {
                path: 'ne_center/sources/mes',
                component: MeList
            },
            {
                path: 'ne_center/eqs',
                name: 'EqList',
                component: EqList
            },
            {
                name: 'PTP',
                path: 'ne_center/ptps',
                component: Ptp
            },
            {
                path: 'ne_center/sources/ptps',
                component: PtpList
            },
            {
                path: 'ne_center/sources/eqs',
                component: EqList
            },
            {
                path: 'ne_center/demo',
                name:'NECenter',
                component: NECenter
            },
            //光模块
            {
                path: 'ne_center/opts',
                component: OptModule
            },
            {
                path: 'ne_center/basic_ctps',
                component: CtpGeneral
            },
            {
                name: 'CTPS',
                path: 'ne_center/ctps',
                component: CTP
            },
            {
                path: '/create/devm',
                component: MeParams,
            },
            //保护组
            {
                path: '/config/pgs',
                component: PGParams
            },
            {
                path: 'ne_center/pgs',
                component: PGList
            },
            {
                path: 'ne_center/lags',
                component: LAG,
            },
            {
                path: '/air/config/upload',
                component: UploadFtpFile
            },
            {
                path: '/air/config/download',
                component: DownloadFtpFile
            },
            {
                path: '/test',
                component: Test
            },
            //告警相关
            {
                path: 'ne_center/alarms',
                component: CurrentAlarms
            },
            {
                path: 'ne_center/alarms&history',
                component: HistoricalAlarms
            },
            {
                path: 'ne_center/alarms&mask',
                component: AlarmsMaskState
            },
            {
                path: '/performances/get-current',
                component: CurrentPerformances
            },
            {
                path: '/performances/get-history',
                component: HistoryPerformances
            },
            {
                path: '/create/eos',
                component: Eos,
            },
            //性能相关
            {
                path: 'ne_center/tcas',
                name:'TCAS',
                component: Tcas
            },
            {
                path: 'ne_center/p/c',
                component: MECurrentPerformanceStatistics
            },
            {
                path: 'ne_center/p/h',
                component: MEHistoryPerformanceStatistics
            },
            {
                path: '/statistics',
                component: Statistics
            },
            {
                path: '/statistics/history',
                component: HistoryStatistics
            },
            {
                path: '/statistics/eth',
                component: EthStatistics
            },
            {
                path: '/statistics/client-eth',
                component: EthClientStatistics
            },
            {
                path: '/statistics/opt',
                component: OPTStatistics
            },
            {
                path: '/statistics/g-metro',
                component: GmetroStatistics
            }


        ]
    },
    {
        path: '/login',
        name: 'Login',
        component: Login
        // component: () => import(/* webpackChunkName: "test" */ '../components/Layout')
    },
    {
        path: '/register',
        name: 'Register',
        component: Register
    },


    // {
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    //component: () => import(/* webpackChunkName: "about" */ '../components/Register')
    // }
]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})
// 路由守卫
// router.beforeEach((to, from, next) => {
//   let isAuthenticated = localStorage.getItem("user");
// if (to.name === 'Layout' && !isAuthenticated) next({ name: 'Login' })
// next()
// })

export default router